package com.controller;

import com.service.OplogService;
import com.util.AjaxResult;
import com.util.Num;
import com.util.UtilCheck;
import com.util.UtilDate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Validated
@RestController
@RequestMapping("/oplog")
@Api(tags = {"操作日志"})
public class OplogController {

    private final static Logger log = LoggerFactory.getLogger(OplogController.class);

    @Autowired
    OplogService oplogService;

    @ApiOperation(value = "分页列表")
    @PostMapping("/list")
    public AjaxResult list(String begin_date,String end_date,
                           @ApiParam(value = "当前页", required = true)
                           @RequestParam
                           @Num(message = "当前页不可用") String pageNum,
                           @ApiParam(value = "每页条数", required = true)
                           @RequestParam
                           @Num(message = "每页条数不可用") String pageSize){
        if(UtilCheck.isEmpty(begin_date)){
            begin_date = UtilDate.plusDay(-7);
        }
        if(UtilCheck.isEmpty(end_date)){
            end_date = UtilDate.nowDate();
        }
        return oplogService.list("",begin_date,end_date,pageNum,pageSize);
    }

}
